package com.kaisa.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.kaisa.activity.R;
import com.kaisa.activity.bean.HomeEntity;
import com.kaisa.activity.bean.MarketingActivities;

import org.xutils.common.util.FileUtil;
import org.xutils.image.ImageOptions;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

/**
 * Created by 123 on 2015/12/14.
 */
public class HomeAdapter extends AppBaseAdapter<MarketingActivities.Position3Entity> {
    private Context context;
    public HomeAdapter(List<MarketingActivities.Position3Entity> list, Context context) {
        super(list, context);
        inflater = LayoutInflater.from(context);
        this.context=context;
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        HomeViewHolder holder = null;
        if(convertView==null){
            convertView = inflater.inflate(R.layout.item_homelistview,null);
            holder = new HomeViewHolder(convertView);
            convertView.setTag(holder);
        }else{
            holder = (HomeViewHolder) convertView.getTag();
        }
        //数据映射
        holder.textView.setText(list.get(position).getShareTitle());
        x.image().bind(holder.imageView,list.get(position).getPic());
        return convertView;
    }
    public static class HomeViewHolder extends BaseViewHolder{
        @ViewInject(R.id.item_img)
        private ImageView imageView;
        @ViewInject(R.id.item_tv)
        private TextView textView;
        public HomeViewHolder(View convertView) {
            super(convertView);
            x.view().inject(this,convertView);
        }
    }
}
